[#19] fix: 토큰 내부 claims로 travelItineraryId와 userId 파싱#21
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the SecondaryTokenAuthenticator to retrieve travelItineraryId from the payload instead of the request URL, removes the now-unused extractTravelDocId method, and updates the server log message accordingly. The reviewer suggested consolidating the validation logic for travelItineraryId to improve code conciseness and maintainability.
Comment on lines
+43
to
+60
| const rawTravelDocId = payload?.travelItineraryId; | ||
| if (typeof rawTravelDocId !== "string" && typeof rawTravelDocId !== "number") { | ||
| return { | ||
| ok: false, | ||
| statusCode: 400, | ||
| message: "Missing travelItineraryId query parameter" | ||
| statusCode: 401, | ||
| message: "Secondary token must include travelItineraryId" | ||
| }; | ||
| } | ||
|
|
||
| const userId = String(rawUserId); | ||
| const travelDocId = rawTravelDocId; | ||
| const travelDocId = String(rawTravelDocId).trim(); | ||
| if (!travelDocId) { | ||
| return { | ||
| ok: false, | ||
| statusCode: 401, | ||
| message: "Secondary token must include travelItineraryId" | ||
| }; | ||
| } |
There was a problem hiding this comment.
travelItineraryId에 대한 유효성 검사 로직이 두 부분으로 나뉘어 있어 중복이 발생하고 있습니다. 이 두 검사를 하나로 통합하여 코드를 더 간결하고 유지보수하기 쉽게 만들 수 있습니다.
const rawTravelDocId = payload?.travelItineraryId;
if (
(typeof rawTravelDocId !== "string" && typeof rawTravelDocId !== "number") ||
String(rawTravelDocId).trim() === ""
) {
return {
ok: false,
statusCode: 401,
message: "Secondary token must include travelItineraryId"
};
}
const userId = String(rawUserId);
const travelDocId = String(rawTravelDocId).trim();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.